﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KaoWuYouLibs.Dal;
using KaoWuYouLibs.Model;

namespace KaoWuYouLibs.Bll
{
    public class QuestionManagementBusiness
    {
        QuestionsAccess access = new QuestionsAccess();

        public List<QuestionModel> FindQuestions(int SubjectID, int SubClassID, string Genre)
        {
            if (Genre != "")
            {
                if (SubjectID != -1)
                {
                    if (SubClassID != -1)
                        return access.FindQuestionsByGenreAndSubjectAndSubclass(Genre, SubjectID, SubClassID);
                    else
                        return access.FindQuestionsByGenreAndSubject(Genre, SubjectID);
                }
                else
                    return access.FindQuestionsByGenre(Genre);
            }
            else
            {
                if (SubjectID != -1)
                {
                    if (SubClassID != -1)
                        return access.FindQuestionsBySubjectAndSubclass(SubjectID, SubClassID);
                    else
                        return access.FindQuestionsBySubject(SubjectID);
                }
                else
                    return access.FindAllQuestions();
            }                
        }

        public bool DeleteQuestion(int QuestionID)
        {
            try
            {
                return access.DeleteQuestion(QuestionID);
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        public bool ImportQuestions()
        {
            throw new NotImplementedException();
        }
    }
}
